using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace Bamboo.Core.Common.Reflection
{
    public class ObjectHelper
    {
        public static object GetPropertyValue(object obj, string propertyName)
        {
            if (obj == null || string.IsNullOrEmpty(propertyName))
            {
                return null;
            }
            PropertyInfo propertyInfo = obj.GetType().GetProperty(propertyName);
            if (propertyInfo != null)
            {
                return propertyInfo.GetValue(obj, null);
            }
            return null;
        }
        public static Type GetTypeFromClassName(string className)
        {
            return Type.GetType(className);
        }
        public static object CreateInstanceFromClassName(string className)
        {
            Type classType = ObjectHelper.GetTypeFromClassName(className);
            if (classType == null)
            {
                return null;
            }
            return classType.Assembly.CreateInstance(classType.FullName);
        }
    }
}
